home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-09 | 3.5 KB | 131 lines | [TEXT/PJMM] |
- {*** This copy of ScoresStubs modified for <your project here>! ***}
-
- {================================================}
- {============= Score handling and display ==============}
- {================================================}
-
- {ScoresStubs is the non-reusable part of the Scores unit in the SAT Add-ons.}
- {You should make a copy for your project and modify it to suit your needs.}
- {You can change the limits (if any), how scores are drawn etc.}
-
-
- unit ScoresStubs;
- interface
-
- {uses SAT, your globals… as necessary}
- uses
- SAT;
-
- const
- kStringSize = 20;
- kListLength = 10;
- kFirstLimit = 100; {Limit for special event, i.e. new life}
- kAskHighDlog = 128; {Id of DLOG resource for asking for name at high score}
- kMargin = 3; {Margin between the text fields in the high score list}
- var
- gNextLimit: Longint;
-
- procedure DoLimit; {Extra life etc.}
-
- procedure DrawScore (score: Longint); {Draw score offscreen}
- procedure DrawScoreImmediate (score: Longint); {Draw score immediately}
-
- implementation
-
- {DoLimit is called whenever the current limit is reached. Here you should add new lives,}
- {show that in any way you see fit, and increase gNextLimit to the next limit! Set gNextLimit}
- {to 0 if there are no more limits.}
- procedure DoLimit;
- begin
- {lives := lives + 1;}
- gNextLimit := gNextLimit * 2;
- {SATSoundPlay(klounkSndH, 15, true);}
- end;
-
- {InternalDrawScore draws the score (and optionally more) at the appropriate place.}
- {Rewrite this for each program!}
-
- function InternalDrawScore (score: Longint): Rect;
- var
- s: str255;
- r: Rect;
- pn: PenState;
- begin
- GetPenState(pn);
- BackColor(blackColor);
- if gSAT.initDepth > 1 then
- ForeColor(redColor)
- else
- ForeColor(whiteColor);
-
- {Set and erase the rectangle in which the score (etc) should be drawn.}
- SetRect(r, 0, 0, gSAT.OffSizeH, 20);
- EraseRect(r);
-
- {Draw the score!}
-
- NumToString(score, s);
- MoveTo(r.left + 20, r.top + 15);
- DrawString('Score: ');
- MoveTo(r.left + 70, r.top + 15);
- DrawString(s);
-
- {Other things you may want to draw include lives, level etc.}
-
- {NumToString(lives, s);}
- {MoveTo(r.left + 200, r.top + 15);}
- {DrawString('Lives: ');}
- {MoveTo(r.left + 240, r.top + 15);}
- {DrawString(s);}
-
- {NumToString(level, s);}
- {MoveTo(r.left + 400, r.top + 15);}
- {DrawString('Level: ');}
- {MoveTo(r.left + 450, r.top + 15);}
- {DrawString(s);}
-
- BackColor(whiteColor);
- ForeColor(blackColor);
- SetPenState(pn);
- InternalDrawScore := r;
- end; {InternalDrawScore}
-
- {DrawScore and DrawScoreImmediate may be useable as they are, as long as you draw}
- {your score in gSAT.backScreen. If you don't, you have to modify them.}
-
- {DrawScore draws the score in gSAT.backScreen and asks SAT to update in the next}
- {turn though SATRun.}
- procedure DrawScore (score: Longint);
- var
- s: Str255;
- r: Rect;
- tmpPort: SATPort;
- begin
- SATGetPort(tmpPort);
- SATSetPortBackScreen;
- r := InternalDrawScore(score);
- SATBackChanged(r); {Nya sättet att dunka saker på skärmen!}
- SATSetPort(tmpPort);
- end; {DrawScore}
-
- {DrawScoreImmediate draws the score in gSAT.backScreen and immediately copies}
- {it to screen.}
- procedure DrawScoreImmediate (score: longint);
- var
- s: str255;
- r: Rect;
- tmpPort: SATPort;
- begin
- SATGetPort(tmpPort);
- SATSetPortBackScreen;
- r := InternalDrawScore(score);
- SATSetPortScreen;
- CopyBits(gSAT.backscreen.port^.portbits, gSAT.wind.port^.portBits, r, r, srcCopy, nil);
- SATSetPortOffscreen;
- CopyBits(gSAT.backscreen.port^.portbits, gSAT.offscreen.port^.portBits, r, r, srcCopy, nil);
- SATSetPort(tmpPort);
- end; {DrawScoreImmediate}
-
-
-
- end.